package cn.edu.scau.cmi.huangmaoqin.simpleFactoryMethod;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

public class GUIController {
	@FXML
	private TextField input;
	@FXML
	private TextArea showText;
	@FXML
	private Button ok;

	// Event Listener on TextField[#input].onAction
	@FXML
	public void Btn_Enter(ActionEvent event) {
		String meatType=input.getText();
		Meat meat = null;
		switch (meatType) {
		case "pork":
			meat = MeatFactory.getMeat("Pork");
			break;
		case "beef":
			meat = MeatFactory.getMeat("Beef");
			break;
		case "chicken":
			meat = MeatFactory.getMeat("chicken");
			break;
		default:
			showText.appendText("incorrect input!\n");
		}
		if (meat != null) {
			showText.appendText(meat.Cook()+"\n");
		}
	}
}
